<?php

function createToolbar(){
    return "<ul>";
}

function endToolbar(){
    return "</ul>";
}


function addButton($text, $link, $linkoption=null ){
    
        /*
         * 
         * $text = text inside the button
         * $link = the link the button points to
         */
        return '<li id='.strtolower(str_replace(" ","_", $text)).'>'.link_to($text,  $link, $linkoption).'</li>';
}

function setToolbar($action, $model, $obj=Null){
    
    $method="set".$action."Toolbar";
    return $method($model,$obj);
    
    
}

function setIndexToolbar($model,$obj){
    
    return "<ul>".
            addButton("Add New", url_for('@'.$model.'_new')).
           "</ul>";
        
}

function setShowToolbar($model, $obj){
    
    if ($model=="powerdev")
        $conf='Are you sure? \nBy a click on yes yuo\'re going to completely remove '.$obj.' and all its related monitored data ?';
    else
        $conf='Are you sure? \nBy a click on yes yuo\'re going to completely remove '.$obj.' ?';
        
    return  "<ul>".
            addButton("Edit", url_for($model.'_edit',$obj)).
            addButton("Delete", url_for($model.'_delete',$obj), array('method'=>'delete','confirm' => $conf)).
            "</ul>";

}

?>
